package app.repositories.impl;

import javax.persistence.EntityManager;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;

import app.models.ParametroSistema;
import app.repositories.ParametroSistemaRepository;
import app.repositories.Repository;
import br.com.caelum.vraptor.ioc.Component;

@Component
public class ParametroSistemaRepositoryImpl extends Repository<ParametroSistema, Long> implements ParametroSistemaRepository{

	private final String NOME = "nome";
	
	protected ParametroSistemaRepositoryImpl(EntityManager entityManager) {
		super(entityManager);
	}
	
	public ParametroSistema findByParam(String nome) {
		Criteria criteria = super.createCriteria();
		
		criteria.add(Restrictions.eq(NOME, nome));
		
		return (ParametroSistema) criteria.uniqueResult();
	}

}
